﻿#ifndef _OI_PLSCANNERCORE_MOTOR_HPP_
#define _OI_PLSCANNERCORE_MOTOR_HPP_

#include "PLScannerCore/OiPLScannerCore.hpp"

namespace Oi
{
    namespace PLScannerCore
    { 
        class OI_PLSCANNER_CORE_API Motor : public QObject
        {
            Q_OBJECT

        public:
            enum AxisStatus
            {
                AS_ALARM = 0x0001,
                AS_HOME_READY = 0x0002,
                AS_LOCATED_READY = 0x0004,
                AS_LOOP_READY = 0x0008,
                AS_AXIS_DIR = 0x0010,
            };

            enum AppendInfo
            {
                AI_SWITCH_ENABLE = 256,
            };

        public:
            Motor();
            ~Motor();

        public:
            void init();
            void exit();
       
        public:
            bool isReady();

            bool isHome();

            bool isAlarm();

            bool loopModeReady();

            bool locatedModeReady();

            bool axisMoveForward();

            double axisPos() const;

            ushort axisStatus() const;

            bool switchEnable () const;

        public slots:
            void loopRun(double vel = 0.0, double form = 0.0, double end = 0.0);

            void locatedRun(double pos = 0.0);

            void loopMode();

            void locateMode();

            void home();

            void stopRun();

            void setResult(int);

        public:
            static Motor* instance();

        private:
            OI_DISABLE_COPY(Motor);
            OI_DECLARE_IMPL(Motor);
        };
    }
}


#endif // _OI_PLSCANNERCORE_ACQUIRE_HPP_
